/**
 * $HeadURL: http://readers-digest.googlecode.com/svn/trunk/readers-digest/src/main/java/by/shade/news/News.java $
 * $Revision: 5 $
 * $Date:: 2012-08-14 16:02:17 +0000 #$
 *
 * Copyright (c) Isida-Informatica, Ltd. All Rights Reserved.
 */
package by.shade.news;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

/**
 * @author homyakov
 * @version $Id: News.java 5 2012-08-14 16:02:17Z vkhomyackov@gmail.com $
 */
public class News implements List<Item> {

    private final List<Item> items = new ArrayList<Item>();

    private String authors;
    private String title;

    public String getAuthors() {
        return authors;
    }

    public void setAuthors(String authors) {
        this.authors = authors;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public int size() {
        return items.size();
    }

    public boolean isEmpty() {
        return items.isEmpty();
    }

    public boolean contains(Object o) {
        if (o instanceof Item) {
            return items.contains(o);
        }
        throw new IllegalArgumentException("Argument should be of class " + Item.class);
    }

    public Iterator<Item> iterator() {
        return items.iterator();
    }

    public Object[] toArray() {
        return items.toArray(new Item[items.size()]);
    }

    public <T> T[] toArray(T[] a) {
        return items.toArray(a);
    }

    public boolean add(Item e) {
        return items.add(e);
    }

    public boolean remove(Object o) {
        if (o instanceof Item) {
            return items.remove(o);
        }
        throw new IllegalArgumentException("Argument should be of class " + Item.class);
    }

    public boolean containsAll(Collection<?> c) {
        return items.containsAll(c);
    }

    public boolean addAll(Collection<? extends Item> c) {
        return items.addAll(c);
    }

    public boolean addAll(int index, Collection<? extends Item> c) {
        return items.addAll(index, c);
    }

    public boolean removeAll(Collection<?> c) {
        return items.removeAll(c);
    }

    public boolean retainAll(Collection<?> c) {
        return items.retainAll(c);
    }

    public void clear() {
        items.clear();
    }

    public Item get(int index) {
        return items.get(index);
    }

    public Item set(int index, Item element) {
        return items.set(index, element);
    }

    public void add(int index, Item element) {
        items.add(index, element);
    }

    public Item remove(int index) {
        return items.remove(index);
    }

    public int indexOf(Object o) {
        if (o instanceof Item) {
            return items.indexOf(o);
        }
        throw new IllegalArgumentException("Argument should be of class " + Item.class);
    }

    public int lastIndexOf(Object o) {
        if (o instanceof Item) {
            return items.lastIndexOf(o);
        }
        throw new IllegalArgumentException("Argument should be of class " + Item.class);
    }

    public ListIterator<Item> listIterator() {
        return items.listIterator();
    }

    public ListIterator<Item> listIterator(int index) {
        return items.listIterator(index);
    }

    public List<Item> subList(int fromIndex, int toIndex) {
        return items.subList(fromIndex, toIndex);
    }

    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("News [");
        if (title != null) {
            builder.append("title=").append(title).append(", ");
        }
        builder.append("items=").append(items).append(", ");
        if (authors != null) {
            builder.append("authors=").append(authors);
        }
        builder.append("]");
        return builder.toString();
    }

}
